package demo4;

import java.util.Objects;

//狗是一个动物并且具备跑和游泳的能力
public class Dog extends Animal implements IRunning,ISwimming{
    public Dog(String name, int age) {
        super(name, age);
    }

    public void eat(){
        System.out.println(this.name+" 正在吃狗粮.....");
    }

    @Override
    public void Running() {
        System.out.println(this.name+" 正在跑");
    }

    @Override
    public void swim() {
        System.out.println(this.name+" 正在游泳");
    }

    @Override
    public boolean equals(Object obj) {
        if(obj==null){
            return false;
        }
        if(!(obj instanceof Dog)){
            return false;
        }
        Dog temp=(Dog) obj;
        return temp.name.equals(this.name)&&temp.age==this.age;
    }

    public int hashCode(){

      return Objects.hash(name,age);
    }
}
